﻿using Volo.Abp.Account;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement;
using CKY.AgentPlatform.PromptTemplates;
using CKY.AgentPlatform.Conversations;
using CKY.AgentPlatform.ModelConfigs;
using CKY.AgentPlatform.Agents;
using CKY.AgentPlatform.Application.McpTools;
using CKY.AgentPlatform.Application.Contracts.McpTools;
using CKY.AgentPlatform.Monitoring;
using CKY.AgentPlatform.Users;
using CKY.AgentPlatform.Mcp;
using CKY.AgentPlatform.Caching;
using Microsoft.Extensions.DependencyInjection;
using CKY.AgentPlatform;
using CKY.AgentPlatform.Domain;

[DependsOn(
    typeof(AgentPlatformDomainModule),
    typeof(AbpAccountApplicationModule),
    typeof(AgentPlatformApplicationContractsModule),
    typeof(AbpIdentityApplicationModule),
    typeof(AbpPermissionManagementApplicationModule),
    typeof(AbpTenantManagementApplicationModule),
    typeof(AbpFeatureManagementApplicationModule),
    typeof(AbpSettingManagementApplicationModule)
    )]
public class AgentPlatformApplicationModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        // 显式注册所有应用服务
        context.Services.AddTransient<IPromptTemplateAppService, PromptTemplateAppService>();
        context.Services.AddTransient<IConversationAppService, ConversationAppService>();
        context.Services.AddTransient<IModelConfigAppService, ModelConfigAppService>();
        context.Services.AddTransient<IAgentAppService, AgentAppService>();
        context.Services.AddTransient<IAgentExecutionAppService, AgentExecutionAppService>();
        context.Services.AddTransient<IMcpToolAppService, McpToolAppService>();
        context.Services.AddTransient<IMcpServerAppService, McpServerAppService>();
        context.Services.AddTransient<IMonitoringAppService, MonitoringAppService>();
        context.Services.AddTransient<IUserAuthAppService, UserAuthAppService>();
        // context.Services.AddTransient<IUserAppService, UserAppService>(); // UserAppService implementation not found

        // 注册其他服务
        context.Services.AddTransient<ICachingService, CKY.AgentPlatform.Application.Caching.CachingService>();
    }
}
